<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>会员卡详情</title>
    <script src="js/flexible.js"></script>
    <link rel="stylesheet" href="css/flexible.css">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/vant.css">
    <link rel="stylesheet" href="layer/need/layer.css">
    <script src="layer/layer.js"></script>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="js/cardShare.js"></script>
    <script src="js/vue/vue.js"></script>
    <script src="js/vue/axios.js"></script>
    <script src="js/vue/MD5.js"></script>
    <script src="js/vue/vant.js"></script>

</head>
<body style="background-color: #F6F6F6;">
<div id="app">
    <div class="card_banner czk" v-if="from.Cardtype=='30'">
        <div class="name">{{from.Cardname}}</div>
        <div class="jg"><span class="l">巨惠价格</span><span class="r">￥{{from.Charge}}</span></div>
        <div class="clear"></div>
    </div>
    <div class="card_banner qxk" v-else-if="from.Cardtype=='10'">
        <div class="name">{{from.Cardname}}</div>
        <div class="jg"><span class="l">巨惠价格</span><span class="r">￥{{from.Charge}}</span></div>
        <div class="clear"></div>
    </div>
    <div class="card_banner csk" v-else>
        <div class="name">{{from.Cardname}}</div>
        <div class="jg"><span class="l">巨惠价格</span><span class="r">￥{{from.Charge}}</span></div>
        <div class="clear"></div>
    </div>
    <div class="card_lc"><img src="images/hyk_lc.png" alt=""></div>
    <div class="mg h10"></div>
    <div class="card_detail">
        <div class="card_title">会员卡详情</div>
        <div class="clear"></div>
        <div class="content">
            <!-- <div class="cimg">
                <img src="images/zwjs.png" alt="暂无介绍">
            </div> -->
            <div class="info membercard">
                <!--暂无介绍暂无介绍暂无介绍-->
                <div class="list">
                    <div class="card">
                        <!-- <div class="cd">
                            <div class="name">{{from.Cardname}}</div>
                            <div class="clear"></div>
                        </div>
                        <div>
                            <div class="l" style="width: 0.7rem">是否可签到</div><div class="r">
                                <span class="zc" v-if="from.SignState=='0'">是</span>
                                <span class="zc"v-else>否</span>
                            </div>
                            <div class="clear jj"></div>
                            <div class="l" style="width: 0.7rem">是否可转让</div>
                            <div class="r" v-if="from.Transfer=='0'">是</div>
                            <div class="r" v-else>否</div>
                            <div class="clear jj"></div>
                            <div class="l" style="width: 0.7rem">余额</div><div class="r">{{from.Term}}</div>
                            <div class="clear jj"></div>
                            <div class="l" style="width: 0.7rem">备注</div><div class="r">{{from.Cardinfo}}</div>
                            <div class="clear jj"></div>
                        </div> -->
                        <div>{{from.Cardinfo}}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="mg h10"></div>
    <div class="kc">
        <div class="card_title">支持课程</div>
        <div class="clear"></div>
        <div class="list">
            <ul>
                <li v-for="item in from.KC_list" :key="item.index">
                    <span class="l">{{item.Title}}</span> <span class="r">（{{item.Chour}}分钟）</span>
                </li>
            </ul>
        </div>
    </div>
    <div class="mg h10"></div>
    <div class="card_coach">
        <div class="card_title">明星教练</div>
        <!-- <div class="all">全部教练</div> -->
        <div class="clear h10"></div>
        <div class="list" v-for="item in from.JL_list">
            <img  :src="item.Picurl" alt="明星教练"><br>
            <span>{{item.Sname}}</span>
        </div>
        <div class="clear"></div>
    </div>
    <div class="card_down" @click="huMoeny" v-if="fromal!='adviser'">
        <div class="btn">立即购买</div>
    </div>
    <div style="display: none;">
        <input ref="desc" id="desc"/>
        <input ref="descTitle" id="descTitle"/>
        <input ref="descImg" id="descImg"/>
    </div>
</div>
</body>
<script>
    var content = $("#yz").html()
    // var content = $("#msg").html()
    $(".btn").click(function () {
        layer.open({
            content: content,
            shadeClose:false,
        });
    })

    $(".close_btn").click(function () {
        console.log(1)
        layer.closeAll()
    })

     new Vue({
         el: '#app',
         data: {
             csid:'',
             coach:[],
             cardList:[],
             address:{},
             myCard:[
               {
                 Cardname:"期限金卡",
                 Cardtype:"期限卡",
                 Surplus:"379天",
                 SignCharge:"入场签到不计费",
                 State:"正常",
                 SEtime:"2019-09-10~2020-09-30",
                 Cardnum:"1111111",
                 codesrc:"/mobileapi/member/barcodegen/barcode.php?code=1111111"
               },
             ],
             from:{},
             token:'',
             fromPhone:{
                phone:'',
                sms_code:''
             },
             vid:'',
             fromal:'',
             share:''
         },
         created(){
             this.setCanS()
         },
         methods:{
             //设置参数
             setCanS(){
                 let Request = new Object()
                 Request = GetRequest()
                 this.csid = Request['csid']
                 this.token = Request['token']
                 this.vid = Request['vid']
                 this.fromal = Request['fromal']
                 this.share = Request['share']
                 if(this.share=="share"){
                    this.fromal=''
                 }
                 if(sessionStorage.getItem('token')!=''&&sessionStorage.getItem('token')!=null&&sessionStorage.getItem('token')!=undefined){
                    this.getDetails()
                    this.kcShare()
                 }else{
                    sessionStorage.setItem('vid',this.vid)
                    this.getToken()
                 }
             },
             //获取会员卡详情
             getDetails(){
                 const params={
                     csid:this.csid
                 }
                 console.log(params)
                 getVs()
                 axios.get('/mobileapi/member/card_info.php?act=getCardInfo',{params:params}).then(data =>{
                     console.log(data.data)
                     let { msg, code,user} = data.data
                         if (code != 200) {
                             _this.$message({
                                 message: msg,
                                 type: 'error'
                             });
                         } else {
                            data=data.data
                            this.from=data.data
                            console.log(this.from)
                            for(let i in this.from.JL_list){
                                if(this.from.JL_list[i].Picurl==''||this.from.JL_list[i].Picurl==null){
                                    this.from.JL_list[i].Picurl='images/fencai.png'
                                }
                            }
                         }
                     }).catch(function (error) {
                         console.log(error);
                 });
             },
             huMoeny(){
                const params={
                     csid:this.csid
                 }
                 console.log(params)
                 getVs()
                 axios.get('/mobileapi/member/card_info.php?act=buyCard',{params:params}).then(data =>{
                     console.log(data.data)
                     let { msg, code,user} = data.data
                         if (code != 200) {
                            window.vant.Toast.fail(msg)
                         } else {
                             data=data.data
                           if(data.type==3){
                            sessionStorage.setItem('ordernum',data.data.OrderNum)
//window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa73c9002cad8e0b3&redirect_uri=https://fitness.guanjialc.com/phone/member/membercard_by.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'
window.location.href=data.payurl+'&Bacurl=http%3a%2f%2ffitness.guanjialc.com%2fphone%2fmember%2findex.html'
                           }else if(data.type==2){
                               window.location.href='bingPhone.html'
                           }else{
                                window.vant.Toast.fail("门店未开通在线支付，请到门店购买")
                           }
                         }
                     }).catch(function (error) {
                         console.log(error);
                 })
             },
             //会员卡详情的分享内容
             kcShare(){
                const params={
                    csid:this.csid
                }
                getVs()
                axios.get('/mobileapi/member/wxfx.php?act=get_hyk_fx',
                {params:params}).then(data =>{
                    console.log(data.data)
                    let { msg, code,user} = data.data
                        if (code !== 200) {

                        } else {
                            data=data.data
                            this.$refs.desc.value=data.data.desc
                            this.$refs.descTitle.value=data.data.title
                            this.$refs.descImg.value=data.data.picurl
                        }
                    }).catch(function (error) {
                        console.log(error);
                })
            },
            //获取分享的token
             getToken(){
                const params={
                    vid:this.vid
                }
                sessionStorage.setItem('logo','0')
                axios.get('/mobileapi/token.php?act=gettoken',{params:params}).then(data =>{
                    console.log(data)
                    let { msg, code,user} = data.data
                        if (code !== 200) {
                            window.vant.Toast.fail(msg)
                        } else {
                            sessionStorage.setItem('token',data.data.Gtoken)
                            this.getDetails()
                            this.kcShare()
                        }
                    }).catch(function (error) {
                        console.log(error);
                });
            }
         }
     })
</script>
</html>
